package larrys.pomodoro.daoimpl.rowmappers;

import java.sql.ResultSet;
import java.sql.SQLException;

import larrys.pomodoro.domain.entity.PomodoroUser;

import org.springframework.jdbc.core.RowMapper;

public class UserRowMapper implements RowMapper<PomodoroUser> {

	@Override
	public PomodoroUser mapRow(ResultSet rs, int rowNum) throws SQLException {
		long id = rs.getLong("id");
		String email = rs.getString("email");
		PomodoroUser user = new PomodoroUser(id, email);
		user.setUsername(rs.getString("user_name"));
		user.setPassword(rs.getString("password"));
		user.setMale(rs.getBoolean("male"));
		user.setExpired(rs.getBoolean("expired"));
		user.setLocked(rs.getBoolean("locked"));
		user.setCredentialsExpired(rs.getBoolean("credentials_expired"));
		user.setEnabled(rs.getBoolean("enabled"));
		return user;
	}

}
